package queueasync;

import java.util.Date;

/**
 * 日志记录任务
 *
 * @author dignwen
 */
public class LogTask implements Task<LogEntity, Boolean> {

    /**
     * 日志实体
     */
    private final LogEntity logEntity;

    public LogTask(LogEntity logEntity) {
        this.logEntity = logEntity;
    }

    @Override
    public LogEntity getData() {
        return this.logEntity;
    }

    @Override
    public Boolean execute() {
        // 数据库存储日志
        try {
            Thread.sleep(10);
            System.out.println("日志内容logEntity = " + logEntity);
            System.out.println("数据库日志存储成功，业务完成~当前时间：" + new Date());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return true;
    }

}

